package org.prowl.torquescan;

import org.prowl.torquescan.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;

/**
 * Activity displayed when application is started
 */
public class PluginActivity extends Activity{
	private Button next;
	private EditText carIdInput;
	private CheckBox temperatureCheck;
	private CheckBox speedCheck;
	private CheckBox consumptionCheck;
	
	private OnClickListener nextListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			Intent intent = new Intent();
			intent.setClass(PluginActivity.this, StartStop.class);
			
			String carId = carIdInput.getText().toString();
			intent.putExtra("carId", carId);
			intent.putExtra("temperature", temperatureCheck.isChecked());
			intent.putExtra("speed", speedCheck.isChecked());
			intent.putExtra("consumption", consumptionCheck.isChecked());
			
            startActivity(intent);  
		}
	};
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		LayoutInflater inflater = LayoutInflater.from(this);
		View view = inflater.inflate(R.layout.config, null);
		carIdInput = (EditText)view.findViewById(R.id.carIdInput);
		
		this.temperatureCheck = (CheckBox)view.findViewById(R.id.temperatureCheck);
		this.speedCheck = (CheckBox)view.findViewById(R.id.speedCheck);
		this.consumptionCheck = (CheckBox)view.findViewById(R.id.consumptionCheck);
		
		this.next = (Button)view.findViewById(R.id.next);
		this.next.setOnClickListener(nextListener);
		setContentView(view);
	}

}
